package com.example.smart.ui.activity.home

import android.view.View
import android.widget.ImageView
import com.example.lib.constants.JumpConstants
import com.example.lib.extend.getIntentString
import com.example.lib.extend.gone
import com.example.lib.extend.setOnDoubleClickListener
import com.example.lib.utils.statusbar.StatusBarUtils
import com.example.smart.R
import com.example.smart.base.ui.activity.BaseActivity
import com.example.smart.databinding.ActivityVideoBinding
import com.yc.video.ui.view.BasisVideoController


class VideoActivity : BaseActivity<ActivityVideoBinding>() {

    override fun layoutID() = R.layout.activity_video

    override fun initView() {
        StatusBarUtils.setStateAndNavigationBar(this@VideoActivity, statusBarColor = com.example.lib.R.color.translate)
        val id = getIntentString(JumpConstants.ID)
        val controller = BasisVideoController(this)

        controller.bottomView
        binding.VideoPlayer.setController(controller)
        binding.VideoPlayer.url = id
        binding.VideoPlayer.start()

        controller.bottomView.findViewById<ImageView>(com.yc.video.R.id.iv_fullscreen).gone()
        val title = controller::class.java.getDeclaredField("titleView")
        title.isAccessible = true
        val titleView = title.get(controller) as View
        titleView.findViewById<ImageView>(com.yc.video.R.id.iv_back).setOnDoubleClickListener {
            finish()
        }
    }

    override fun onDestroy() {
        binding.VideoPlayer.release()
        super.onDestroy()
    }

}